<?

if($p_info['p_type']=='H'){
	include 'productOrder_show.html';
	exit;
}
try{
	$p->saleCheck();//查看产品是否在售
}catch(ProductInfoException $e){
	getOut("home.html",$e->getMessage());
}

if($p_info['p_type']=='F'){// 套票
	include_once("/var/www/html/new/d/class/PackTicket.class.php");
	$lid = $p_info['lid'];
	$pack = new PackTicket($lid);
	$useDate = $pack->useDate();
	$mintime = substr($useDate['sDate'],0, 10);// 有效开始时间
	$maxtime = $useDate['mDate'] ? $useDate['mDate']:'2020-10-10';// 有效结束时间
	// 使用开始时间大于结束时间或查看的月份大于最大月份，套票无效
	$begintime = (substr($useDate['sDate'],0,10) > substr($useDate['eDate'],0,10)) ? -1:$mintime;//
	if($begintime==-1) getOut("home.html","无有效出行日期，请更换产品");
}
$begintime = $p->getMinValidTime($begintime);/*产品有效起始日期*/
if($begintime==-1) getOut("home.html","无有效出行日期，请更换产品");
if(!$p->supply($memberID)) getOut("home.html","无购买权限");
if($begintime<date('Y-m-d')) $begintime = date('Y-m-d');

// $jsprice = $p->jsPrice_n($begintime);//返回产品分销价
$xml = $s->Dynamic_Price_And_Storage($_SESSION['saccount'], $pid, $begintime, 1, 0, 1, $aid);
if($xml==105 || $xml==1065 || $xml==101) getOut($_SERVER['HTTP_REFERER'],"无有效出行日期，请更换产品");
$object = simpleXML_load_string($xml);
$jsprice = (int)$object->Rec->UUsprice;
//$storage = ((string)$object->Rec->UUstorage==-1) ? '不限':(string)$object->Rec->UUstorage;
$storage = $p->dayStorage($begintime);
$uprice = $p->uPrice_n($begintime);//返回产品零售价
$buynum = $p_info['buy_limit_low'] ? $p_info['buy_limit_low']:1;

// if(is_array($jsprice)) getOut($_SERVER['HTTP_REFERER'],"无有效出行日期，请更换产品");
// 产品信息
$payMethod = $p_info['pay'];
$products=array();
$products[]=array(
	"pid"       => $pid,
	"id"        => "purchaseNum",
	"name"      => "tnum",
	"ttitle"    => $p_info['ttitle'].($p_info['v_time_limit']==0 ? '' : '(<span style="color:#F33">验票时间'.str_replace('|', '至', $p_info['v_time_limit']).'</span>)'),
	"buynum"    => $buynum,
	"jsprice"   => $jsprice,
	"uprice"    => $uprice,
	"tprice"    => $p_info['tprice'],
	"minTime"   => $begintime,
	"ddays"     => $p_info['ddays'],
	"buy_limit_low" => $p_info['buy_limit_low'],
	'buy_limit_up'  => $p_info['buy_limit_up'],
	'pay'       =>$p_info['pay'],
	'sendVoucher'=>$p_info['sendVoucher'],
	'order_start'=>$p_info['order_start'],
	'order_end'=>$p_info['order_end'],
    'reb'=>$p_info['reb'],
    'reb_type'=>$p_info['reb_type'],
    'storage'=>$storage,
);

if($p_info['p_type']=='F'){// 套票
	// 产品有效期
	$products[0]['valid'] = '';
}else{
	// 产品有效期
	$valid = _htmlValid($p_info);
	$products[0]['valid'] = $valid;
	if ( $p_info['p_type']!="F" && $p_info['v_time_limit']==0 && $p_info['sync_status']!=2) {
		$c_pros=$m->salePros($p_info['lid']);// 该景区下的其他门票
		foreach($c_pros as $row){
			if($row['sapply_did']!=$_REQUEST['aid'] && $row['apply_did']!=$_SESSION['sid']) {
                    continue;
			}
			if($row['order_start']!=$p_info['order_start']) continue;
			if($row['order_end']!=$p_info['order_end']) continue;
			if($row['ddays']!=$p_info['ddays']) continue;
			if($row['delaydays']!=$p_info['delaydays']) continue;
			if($row['order_limit']!=$p_info['order_limit']) continue;
			if($row['tourist_info']!=$p_info['tourist_info']) continue;
            /*
            *之前$c_pros里没有取tourist_info 值是Null
            *而$p_info里的tourist_info的值是字符串的'0'
            *两者不相等 因此联票都显示不出来
            */
			$c_pids[]=$row['pid'];
		}
		if (count($c_pids)) {
			foreach($c_pids as $c_pid){
				if($c_pid==$p_info['pid']) {
                    continue;
                }else{
                    $apro=new ProductInfo($s,$c_pid,$aid);
                    $storage1= $apro ->dayStorage($begintime);
                }
				try{
					// $c_jsprice=$apro->jsPrice($memberID,$begintime);
					// $c_uprice=$apro->uPrice($memberID,$begintime);
					
					$c_jsprice=$apro->jsPrice_n($begintime);
					if($c_jsprice==-1 || is_array($c_jsprice)) continue;
					$c_uprice=$apro->uPrice_n($begintime);
					if($c_uprice==-1) continue;
					$c_pro=$apro->pInfo();
					
					if($c_pro['v_time_limit'] != 0 || $c_pro['sync_status']==2) continue;//验票时间是否不限
					if($c_pro['pay'] !=$payMethod) continue;
					// 
					if($products[0]['sendVoucher']!=$c_pro['sendVoucher'])continue;
					$time=strtotime($begintime)+($c_pro['ddays']-$p_info['ddays'])*24*3600;
					$minTime=date("Y-m-d",$time);
					$products[]=array(
                        "pid"=>$c_pro['pid'],
                        "id"=>$c_pro['id'],
                        "name"=>"c_pids[".$c_pid."]",
                        "ttitle"=>$c_pro['ttitle'],
                        "buynum"=>0,
                        "jsprice"=>$c_jsprice,
                        "uprice"=>$c_uprice,
                        "tprice"=>$c_pro['tprice'],
                        "minTime"=>$minTime,
                        "buy_limit_low"=>$c_pro['buy_limit_low'],
                        'buy_limit_up'=>$c_pro['buy_limit_up'],
                        'valid'=>_htmlValid($c_pro),
                        'order_start'=>$c_pro['order_start'],
                        'order_end'=>$c_pro['order_end'],
                        'reb'=>$c_pro['reb'],
                        'reb_type'=>$c_pro['reb_type'],
                        'storage'=>$storage1,
                    );
				}catch(Exception $e){
					//结算价未设置
				}
			}
		}
	}
	
}
//供应商信息
$str = "select dname,qq,mobile,cname from pft_member where id=".$p_info['sapply_did']." limit 1";
$GLOBALS['le']->query($str);
$a_info = $GLOBALS['le']->fetch_assoc();


//产品说明
$timeTitle=($p_info['ddays']==0)?"有效期内，可预订当天门票":"有效期内，需提前".($p_info['ddays'])."天预订";
$unitT=$p_info['p_type']=="C"?"间":"张";
$tips=$p_info['ddays']>0?"需提前".$p_info['ddays']."天预订，":"可预订当日票，";
$tips.=$p_info['buy_limit_low']>0?$p_info['buy_limit_low'].$unitT."起订，":"1".$unitT."起订，";
if($p_info['p_type']=="A"){
	$tips.=($p_info['delaydays']>0)?"游玩日期起".$p_info['delaydays']."天内有效，":"游玩日期当日有效，";
}
$tips.=($p_info['status']!=0)?"<i>".($p_info['mdays']!=0?"自动":"人工")."确认</i>后生效，":"";
$tips=$tips.$p_info['notes'];


//金额
$v['tmoney'] = $m->tmoney($p_info['sapply_did']);//查询会员账户可用授信额度
$v['money'] = $m->money();//查询会员账户余额
$cinfos = $m->cinfos(-1);//查询常用联系人

if($v['tmoney']>$jsprice*$tnum){
	$paymodeCheck0="";
	$paymodeCheck1="";
	$paymodeCheck2="checked";
}elseif($v['money']>$jsprice*$tnum){
	$paymodeCheck0="checked";
	$paymodeCheck1="";
	$paymodeCheck2="";
}else{
	//$paymodeCheck0="checked";//暂时关闭支付宝
	$paymodeCheck0="";
	$paymodeCheck1="checked";
	$paymodeCheck2="";
}

$token = '6f0c6c49daa58b9d802189ac932dcd65';
$appid = base64_encode('www.12301.cc');


if($p_info['p_type']!='C'){
    $land_f_info = $p_info;
}


$sql = "select uuid from uu_jq_ticket where id={$p_info['tid']} limit 1";
$GLOBALS['le']->query($sql);
$GLOBALS['le']->fetch_assoc();
$uuid = $GLOBALS['le']->f('uuid');
$date_format = array('周日','周一','周二','周三','周四','周五','周六');
?>
<link type="text/css" rel="stylesheet" href="css/ui/Calendar.css" media="screen" />
<link type="text/css" rel="stylesheet" href="css/productOrder.css" media="screen" />
<script src="http://www.16u.cc/d/js/popBox.js"></script>
<style>
    #contactList{margin-bottom:10px; background:#f3faff; padding:10px;}
    #contactList li{ float:left; margin-right:20px; width:80px; text-align:center}
    #contactList li input{vertical-align:-2px; margin-right:2px;}
    .oper{ cursor:pointer}
    #popBox{ text-align:left; border:8px solid #767576; padding:20px;}
    .close{cursor:pointer;position:absolute; right:20px;top:10px;text-align:center;  font-size:14px; font-weight:bold;}
    #popBox h3{ color:#265895;font-weight:bold}
    #popBox textarea{ width:300px; height:80px;}
    #popBox  input.btn{padding:5px 10px; margin-right:20px; cursor:pointer; font-size:12px; }
    span.note_name{color:red;}
</style>
<div class="clay">
<input type="hidden" id="remaindMoney" value="<?=$v['money']?>"/>
<input type="hidden" id="remainTmoney" value="<?=$v['tmoney']?>"/>
<input type="hidden" id="minbuytnum" value="<?=$p_info['buy_limit_low']?>"/>
<input type="hidden" id="pay" value="<?=$p_info['pay']?>"/>
<input type="hidden" id="tourist_info" value="<?=$land_f_info['tourist_info']?>"/>
<form action="/module/api/glyld/glyld_submitOrder.php" method="post" name="group">
<input type="hidden" name="pid" id="pid" value="<?=$pid?>"/>
<input type="hidden" name="aid" id="aid" value="<?=$aid?>"/>
<h2>
    <a target="_blank" href="scenicDetail.html?lid=<?=$p_info['lid']?>&did=<?=$memberID?>"><?=$p_info['ltitle']?></a>
</h2>
<div class="proBd">
<div class="contactW ">
    <h3 class="title">
        <span class="title">预订信息</span>
    </h3>
    <div class="box">
        <div class="ticketlist">
            <?php if($p_info['p_type']=="C"):?>
            <?php $leavetime=date("Y-m-d",strtotime($begintime)+24*3600);?>
            <p class="roomType line">
                <span class="lTitle">房间类型：</span>
                <?=$p_info['ttitle']?>
            </p>
            <p class="rooms line">
                <span class="lTitle"><i class="red">*</i>预订间数：</span>
                <select id="roomNum" name="tnum">
                    <?php for($j=$buynum;$j<=20;$j++):?>
                    <option value="<?=$j?>"><?=$j?>间</option>
                    <?php endfor;?>
                </select>
            </p>
            <p class="playtime line">
                <span class="lTitle"><i class="red">*</i>入住日期：</span>
                <input type="text" name="begintime" id="begintime" class="inputText" value="<?=$begintime?>"/>
                <span class="lTitle"><i class="red">*</i>离店日期：</span>
                <input type="text" name="leavetime" id="leavetime" class="inputText" value="<?=$leavetime?>"/>
            </p>
            <ul class="priceItem">
				<li>
					<div class="title"> <?=substr($begintime,5)?>(<?=$date_format[date('N')]?>)</div>
					<input type="hidden" value="<?=$jsprice/100?>">
					<div class="priItem">
						<span>¥<?=$jsprice/100?></span><br>
						<span><?=$storage?></span>
						<input type="hidden" class="tnum" value="1">
					</div>
				</li>
			</ul>
            <?php else:?>
            <p class="playtime line">
                <?php if($p_info['p_type']=="A"||$p_info['p_type']=="B"||$p_info['p_type']=="F"||$p_info['p_type']=="G"):?>
                <span class="lTitle"><i class="red">*</i>游玩日期：</span>
                <input type="text" name="begintime" id="begintime" class="inputText" value="<?=$begintime?>"/>
                (<?=$timeTitle?>)&nbsp;&nbsp;<span style="color:red;"><?=$valid?></span>
				<span>
					<select name="flight_time">
					<?=$selectTxt?>
					</select>
				</span>
                <?php elseif($p_info['p_type']=="D"):?>
                <input type="hidden" name="begintime" id="begintime" class="inputText"  value="<?=$begintime?>"/>
                <?php endif;?>
                <!--鼓浪屿轮渡信息-->
                <?php
                        if($_GET['pzp']){
                        ?>
                <span class="lTitle">出发时间：</span>
					<select name="cooperation_way" id="bindLista" class="selectcss">
						<?=$selectTxt?> 
					</select>
                <?}?>
            </p>
            <table id="tbTickets" class="listCon proTable type<?=$p_info['p_type']?>" style="width:100%;">
                <thead>
                <tr>
                    <th class="list_1">产品名称</th>
                    <th>产品库存</th>
                    <th class="price">门市价</th>
                    <th class="price">建议零售价</br><span class="s_note">(低于零售价将按协议处罚)</span></th>
                    <th class="price">结算价</th>
                    <th>预订数量</th>
                    <th>小计</th>
					<th>退票手续费</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach($products as $row):?>
                <tr class="line <?=++$pn>3?"more display_none":""?>">
				<input type="hidden" class="order_start" value="<?=$row['order_start']?>" />
				<input type="hidden" class="order_end" value="<?=$row['order_start']?>" />
                <td class="list_1 list"><?=$row['ttitle']?></td>
                <td><em class="storage_<?=$row['pid']?>"><?=$row['storage'] ?></em></td>
                <td class="list_2 list"><em class="price">¥<?=(int)$row['tprice']?></em></td>
                <td class="list_2 list" data-p="<?=$row['uprice']?>"><em class="price jprice uprice_<?=$row['pid']?>">¥<?=$row['uprice']/100?></em></td>
                <td class="list_3 list"><em class="price jprice tprice_<?=$row['pid']?>">¥<?=$row['jsprice']/100?></em></td>
                <td class="list_4 list">
                    <input type="hidden" class="tprice_<?=$row['pid']?>" value="<?=$row['jsprice']/100?>"/>
                    <div class="jiajian">
                        <a href="#" class="jian jjBtn J_jianBtn minus">减一张</a>
                        <input type="text" id="<?=$row['id']?>" name="<?=$row['name']?>" value="<?=$row['buynum']?>" p_minTime="<?=$row['minTime']?>" p_minbuy="<?=$row['buy_limit_low']?>" class="input_text tnum">
                        <a href="#" class="jia jjBtn J_jiaBtn add">加一张</a>
                    </div>
                </td>
                <td class="list_6 list totalprice">¥<em class="subtotal"><?=$row['buynum']*$row['jsprice']/100?></em></td>
				<td>
                    <?=$row['reb_type']==1?'固定费用':'百分比'?>
                    <?=$row['reb_type']==1?$row['reb']/100:$row['reb'].'%'?>
                </td>
                </tr>
            <?php endforeach;?>
                </tbody>
            </table>
    <?php if(count($products)>3):?>
    <p class="addTicket">
                <a class="fr show_more">显示所有门票类型</a>
            </p>
    <?php endif;?>
    <?php endif;?>
        </div>
        <div class="clear"></div>
    <?php if($ass_station=unserialize($land_f_info['ass_station'])):?>
    <p class="line">
            <span class="lTitle"><i class="red">*</i>集合地址：</span>
            <select name="assembly">
                <?php foreach($ass_station as $key=>$station):?>
                <option value="<?=$key?>"><?=$station?></option>
                <?php endforeach;?>
            </select>
        </p>
    <?php endif;?>
    </div>
</div>
        <!--管理常用联系人-->
<textarea id="pop_tpl" style="display:none">
<div id="popBox">
	<a class="close" onclick="popBox.close()">X</a>
	<h3>常用联系人管理</h3>
	<form  id="form1" action="../cutinfo.php" method="post" name="haha">
        <div id="contactList">
            <ul>
			   
                <?php foreach($cinfos as $cname=>$cmobile):?>
                <li>
                    <input id="testInput" type="checkbox" name="cutname[]" value="<?=$cname?>">
                    <span class="name"><?=$cname?></span>	
                </li>
                <?php endforeach;?>
				
            </ul>
            <p class="cl"></p>
        </div>
      <input  type="submit" id="Submit" value="删 除"/>
	</form>
 </div>
</textarea>
        <!--管理常用联系人结束-->





<div id="RecommendProducts" class="contactW"></div>
<div class="contactW ">
    <h3 class="title">
        <span class="title">联系人信息</span>（请准确填写联系人信息，我们将向联系人手机发送订单短信）
        <span class="save"><input type="checkbox" checked value="1" name="saveTo" class="inputText"/>保存到常用联系人</span>
		<a class="oper" orderid="" inputV="">操作</a>
    </h3>
    <div class="box">
        <?php if(count($cinfos)>0):?>
        <div id="contactList">
            <ul>
                <?php foreach($cinfos as $cname=>$cmobile):?>
                <li>
                    <input type="checkbox" value="<?=$cmobile?>">
                    <span class="name"><?=$cname?></span>
                </li>
                <?php endforeach;?>
            </ul>
            <p class="cl"></p>
        </div>
        <?php endif;?>
        <p class="line">
            <span class="lTitle"><i class="red">*</i>联系人：</span>
            <input type="text" class="inputText" id="ordername" autocomplete="off" name="ordername"/>
			<span class="note_name"></span>
		</p>
        <?if($_GET['pzp']){?>
        <p class="line">
				<span class="lTitle"><i class="red">*</i>身份证：</span>
				<input type="text" style="width:400px"  class="inputText" id="IDnum" name="IDnum">
			</p>
        <?}?>
        <p class="line">
            <span class="lTitle"><i class="red">*</i>手机号码：</span>
            <input type="text"  class="inputText" id="ordertel" name="ordertel">
            (接收订单短信，请务必正确填写)
        </p>
        <p class="line">
            <span class="lTitle">备注信息：</span>
            <input type="text" style="width:400px"  class="inputText" id="memo" name="memo">
        </p>
        <?if($m_info['cname']&&$m_info['ctel']){
                $cname=explode("|",$m_info['cname']);
                $ctel=explode("|",$m_info['ctel']);
                ?>
        <div class="contactWrap" id="contactWrap">
            <div class="content">
                <a class="closebtn"></a>
                <h4>您可以选择以下常用联系人：</h4>
                <ul>
                    <?for($i=count($cname)-1;$i>=0;$i--){
                            if(!$cname[$i]) continue;
                            ?>
                    <li>
                        <input type="checkbox" value="<?=$ctel[$i]?>" />
                        <span class="name"><?=$cname[$i]?></span>
                    </li>
                    <?}?>
                </ul>
                <p class="clear">&nbsp;</p>
            </div>
        </div>
        <?}?>
    </div>
</div>
<div class="">
    <h3 class="title"><span class="title">供应商信息</span></h3>
    <div class="box orderinfo">
        <p>
            <span>供应商名称：<?=$a_info['dname']?></span>
            <?php if($a_info['qq']):?>
            <span>QQ：<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=<?=$a_info['qq']?>&site=qq&menu=yes"><img onerror="this.parentNode.removeChild(this)" style="vertical-align:-5px" border="0" src="http://wpa.qq.com/pa?p=2:<?=$a_info['qq']?>:52" alt="点击这里给我发消息" title="点击这里给我发消息"/></a></span>
            <?php endif;?>
            <span>联系人：<?=$a_info['cname']?> <?=$a_info['mobile']?></span>
        </p>
    </div>
</div>
        <?php if($land_f_info['p_type']=='C'):?>
<div class="guest">
    <h3 class="title"><span class="title">入住信息</span></h3>
    <div class="box roomInfo">
        <?php if($land_f_info['tourist_info']>0):?>
        <p class="line">
            <span class="lTitle"><i class="red">*</i>入住人姓名：</span>
							<span class="roomDiv">
								<input type="text" class="inputText roomer gray" id="roomer" name="tourist_name_1" value="入住人1"/>
								<span class="ts">(请填写实际入住人姓名，每个房间只需填1位)</span>
							</span>
        </p>
        <?php endif;?>
        <div class="clear"></div>
        <p class="arriveTime line">
            <span class="lTitle"><i class="red">*</i>最晚到店：</span>
            <select class="" name="arriveTime" id="arriveTime">
                <option value="">请选择时间</option>
                <option>15:00</option>
                <option>16:00</option>
                <option>17:00</option>
                <option>18:00</option>
                <option>19:00</option>
                <option>20:00</option>
                <option>21:00</option>
                <option>22:00</option>
                <option>23:00</option>
                <option>24:00</option>
                <option>次日1:00</option>
                <option>次日2:00</option>
                <option>次日3:00</option>
                <option>次日4:00</option>
                <option>次日5:00</option>
            </select>
        </p>
    </div>
</div>
        <?php elseif($land_f_info['tourist_info']>0):?>
<div class="contactW ">
    <h3 class="title"><span class="title">旅客信息</span>（儿童证件号码请填写出生日期）</h3>
    <div class="box tourist">
        <?php if($land_f_info['tourist_info']==1):?>
        <div class="info">
            <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
							<span>
								<select class="tourist_type" style="display:none">
                                    <option value="1">成人</option>
                                </select>
							</span>
							<span>
								<label class="lt"><i class="red">*</i>姓名:</label>
								<input type="text" name="tourist_name_1" class="tourist_name">
							</span>
							<span>
								<label class="lt"><i class="red">*</i>身份证号:</label>
								<input type="text" name="tourist_cert_1" class="tourist_cert" >
							</span>
        </div>
        <?php else:?>
        <?php for($i=1;$i<=$buynum;$i++):?>
        <div class="info">
            <span>第<?=$i?>位游客</span>
                                <span>
                                    <select class="tourist_type">
                                        <option value="1">成人</option>
                                        <option value="0">儿童</option>
                                    </select>
                                </span>
                                <span>
                                    <label class="lt"><i class="red">*</i>姓名:</label>
                                    <input type="text" name="tourist_name_<?=$i?>" class="tourist_name">
                                </span>
                                <span>
                                    <label class="lt"><i class="red">*</i>身份证号:</label>
                                    <input type="text" name="tourist_cert_<?=$i?>" class="tourist_cert" >
                                </span>
        </div>
        <?php endfor;?>
        <?php endif?>
    </div>
</div>
        <?php endif;?>
<div class="contactW ">
    <h3 class="title"><span class="title">支付方式</span></h3>
    <div class="box">
        <?php if($p_info['apply_did']==$memberID):?>
        <p style="padding-left:20px;">预订自供产品，无需支付</p>
        <input type="hidden" value="3" name="paymode"/>
        <?php elseif ($payMethod==0):?>
        <p style="padding-left:20px;">现场支付</p>
        <input type="hidden" value="4" name="paymode" />
        <?php else:?>
        <p class="line pmodel" style="padding-left:20px;">
            <input class="paymode" type="radio" name="paymode" <?=$paymodeCheck2?> value="2" >
            <span class="credit">授信余额<label> (可用<em class="money">¥<?=$v['tmoney']/100?></em>)</label></span>
            </br>
        <?if(!$access['yd']):?>
        <input class="paymode" type="radio" value="0" <?=$paymodeCheck0?> name="paymode">
            <span>账户余额<label> (可用<em class="money">¥<?=$v['money']/100?></em>)</label></span>
            </br>
    <?endif;?>
    <input class="paymode" type="radio" value="1" <?=$paymodeCheck1?> name="paymode">
            <span>在线支付</span>
        </p>
        <?php endif;?>
        </div>
        </div>

        </div>
<div class="totalCount">
    <p class="con">
        <a href="#" class="submitBtn"></a>
        <i class="icon"></i>
        <?php if($p_info['p_type']!="C"):?>
        <span class="span1">门票数：<em id="sumtnum" class="num"><?=$buynum?></em>张</span>
        <?php endif;?>
        <span class="span2">总金额：<em id="summoney" class="num"><?=$buynum*$jsprice/100?></em>元</span>
    </p>
</div>
<div class="about">
    <h3 class="title"><span class="title">预订须知</span></h3>
    <div class="content">
        <h3>购票需知：</h3>
        <?=nl2br($p_info['jqts'])?>
        <h3>产品说明：</h3>
        <?=$tips?>
        <h3>取票信息：</h3>
        <?=$p_info['getaddr']?>
    </div>
</div>
        </form>
        </div>
        </div>
<script type="text/html" id="tourist_tmpl">
    <div class="info">
        <span>第{:num}位游客</span>
		<span>
			<select class="tourist_type">
                <option value="1">成人</option>
                <option value="0">儿童</option>
            </select>
		</span>
		<span>
			<label class="lt"><i class="red">*</i>姓名:</label>
			<input type="text" name="tourist_name_{:num}" class="tourist_name">
		</span>
		<span>
			<label class="lt"><i class="red">*</i>身份证号:</label>
			<input type="text" name="tourist_cert_{:num}" class="tourist_cert" >
		</span>
    </div>
</script>
<script type="text/html" id="pri_tmpl">
    <li>
        <div class='title'> {:date}({:weekT})</div>
        <input type="hidden" value="{:jsprice}"/>
        <div class="priItem">
            <span>¥{:jsprice}</span></br>
            <span>{:roomStatus}</span>
            <input type="hidden" class="tnum" value="{:tnum}"/>
        </div>
    </li>
</script>
<script type="text/html" id="roomer_tmpl">
    <input type="text" class="inputText roomer more gray" name="tourist_name_{:i}" value="入住人{:i}"/>
</script>
<script type="text/javascript" src="js/jquery.getareas.js" type="text/javascript"></script>
<script type="text/javascript" src="js/global/Date_func.js"></script>
<script type="text/javascript" src="js/ui/JsTpl.js"></script>
<script type="text/javascript" src="js/ui/PopWindow.js"></script>
<script type="text/javascript" src="js/form/Verify.js"></script>
<script type="text/javascript">
var Calendar={
	popBox:new PopWindow(),
	init:{
			timeElement:null,
			handles:[]
		},
	data:{},
	datePrice:{},
	dateStorage:{},
	strpad:function(str){
		str=String(str);
		if(str.length==1){
			return "0"+str;
		}else{
			return str;
		}
	},
	outputHtml:function(json,yearmonth,fromDate){
		var d={};
		for(r in json){
			d[r.date]=r.price;
		}		
		var nowtime=new Date();
			if(fromDate){
				fromDate=fromDate.split("-");
				fromDate=fromDate.join("/");
				if((new Date(fromDate)).getTime()>nowtime)
				 nowtime=(new Date(fromDate));
			}
			nowtime.setHours(0,0,0,0);
			nowtime=nowtime.getTime();//凌晨时间
			
			
		var begintime=yearmonth+"-01";
			begintime=begintime.split("-");
			begintime=begintime.join("/");
		var beginDate=new Date(begintime);
		var year=beginDate.getFullYear();
		var month=beginDate.getMonth()+1;
		var lastmonth=(month-1==0)?12:month-1;
		var nextmonth=(month+1==13)?1:month+1;
		var days=(new Date(beginDate.getFullYear(),beginDate.getMonth()+1,0)).getDate();
		var monthdays=days;
		var emptydays=beginDate.getDay();
		var endtime=yearmonth+"-"+days;
			endtime=endtime.split("-");
			endtime=endtime.join("/");
		var endDate=new Date(endtime);
		days+=beginDate.getDay()+(7-endDate.getDay());

		beginDate.setTime(beginDate.getTime()-(24*3600000*beginDate.getDay()));
		var lastmonth_none=(json.about.mintime*1000-beginDate.getTime()<0)?"":"lastmonth_none";
		var nextmonth_none=(json.about.maxtime*1000-endDate.getTime()>0)?"":"nextmonth_none";
		var html='<div class="calendar" id="calendarContent"><div class="monthbox">'+
					'<div class="title"><span class="lastmonth '+lastmonth_none+'"><a title="'+lastmonth+'月">&nbsp;</a></span><span class="nextmonth '+nextmonth_none+'"><a title="'+nextmonth+'月">&nbsp;</a></span><span class="year">'+year+'年'+month+'月</span><span class="close"></span></div>'+
						'<table>'+
							'<tr>'+
								'<th class="weeken">日</th>'+
								'<th>一</th>'+
								'<th>二</th>'+
								'<th>三</th>'+
								'<th>四</th>'+
								'<th>五</th>'+
								'<th class="weeken">六</th>'+
							'</tr>';
		for(var i=0,j=0;i<days-1;i++){
			if(i%7==0){
				html+='<tr>';
			}
			var date=beginDate.getFullYear()+"-"+this.strpad((beginDate.getMonth()+1))+"-"+this.strpad(beginDate.getDate());
			var price="";
			var priceT="";
			var valid="";
			var validT="";
			var remain;
			if(json.pricelists[j]&&json.pricelists[j].date==date){
				this.datePrice[date]=json.pricelists[j].price;
				this.dateStorage[date]=json.pricelists[j].storage;
				price=json.pricelists[j].price;
				priceT=json.pricelists[j].price?"¥"+json.pricelists[j].price:"";
				priceT="¥"+json.pricelists[j].price;
				valid="valid";
				j++;
			}
			if(i<emptydays||i>=monthdays+emptydays){
				html+='<td><div class="detail"></div></td>';
			}else if(beginDate.getTime()<nowtime){
				html+='<td><div price="'+price+'" date="'+date+'" class="detail"><span>'+beginDate.getDate()+'</span><div class="price"></div></div></td>';
			}else{
				html+='<td><div price="'+price+'" date="'+date+'" class="detail '+valid+'"><span>'+beginDate.getDate()+'</span><div class="price">'+priceT+validT+'</div></div></td>';
			}
			if(i%7==6){
				html+='</tr>';
			}
			beginDate.setTime(beginDate.getTime()+24*3600000);
		}
		html+="</table></div>";
		return html;
	},
	show:function(yearmonth,pid,fromDate,aid){
		var html;
		if(this.data[yearmonth]){
			html=this.outputHtml(this.data[yearmonth],yearmonth,fromDate);
		}else{
			$.ajax({
				url:"call/route_Calendar_Ajax.php",
				async:false,
				type:"GET",
				dataType:"json",
				data:{"orderMonth":yearmonth,"pid":pid, "aid":aid},
				success:function(json){
					html=Calendar.outputHtml(json,yearmonth,fromDate);
					Calendar.data[yearmonth]=json;
				}
			})
		}
		Calendar.popBox.open(html);
		$("#calendarContent div.valid").click(function(){//选择日期
			
			var sdate = $(this).attr("date");
			$.ajax({
				url:"http://www.12301.cc/module/api/glyld/getDailyFlight_json.php",
				async:false,
				type:"GET",
				dataType:"json",
				data:{"hlineid":"<?=$uuid?>","sdate":sdate},
				success:function(json){
					var select = '',time = '';
					for(var i in json.list){
						time = json.list[i].departTime.substr(10).trim();
						select+= '<option value="'+json.list[i].dailyFlightGid+'_'+time+'">'+time+'----'+json.list[i].offLineFreeCount+'</option>';
					}
					$("select[name=flight_time]").html(select);
					
				}
			});
			

			Calendar.init.timeElement.value=$(this).attr("date");
            //触发change事件_added by cgp BEGIN
            $(Calendar.init.timeElement).trigger('change');
            //触发change事件_added by cgp END
			Calendar.popBox.close();
			for(var i=0;i<Calendar.init.handles.length;i++){
				Calendar.init.handles[i](this);
			}	
		})
		$("#calendarContent span.close").click(function(){
			Calendar.popBox.close();
		})
		var time=yearmonth+"-01";
			time=time.split("-");
			time=time.join("/");
			time=new Date(time);
		var lasttime=new Date(time.getFullYear(),time.getMonth()-1,1);
		var nexttime=new Date(time.getFullYear(),time.getMonth()+1,1);
		var lastmonth=lasttime.getFullYear()+"-"+this.strpad(lasttime.getMonth()+1);
		var nextmonth=nexttime.getFullYear()+"-"+this.strpad(nexttime.getMonth()+1);
		$("#calendarContent .lastmonth").click(function(){
			Calendar.show(lastmonth,pid,fromDate,aid);
		})
		$("#calendarContent .nextmonth").click(function(){
			Calendar.show(nextmonth,pid,fromDate,aid);
		})
	}
};
</script>
<script type="text/javascript" src="js/productOrder.js"></script>
<?php if($p_info['p_type']=='F'):?>
<script>
<? include '/var/www/html/new/d/module/link_product/child_tickets.js';?>
</script>
<?php else:?>
<script>
<? include '/var/www/html/new/d/module/link_product/link_product.js';?>
</script>
<?php endif;?>


<script>
var popBox=new PopWindow();
var oper=function(elem,tag){
    var textarea=$(elem).parent().find("textarea");
    if(tag==1){
        $("#popBox .Ddstatus").val("1");
        $("#popBox form").submit();
    }else{
        $("#popBox .Ddstatus").val("2");
        $("#popBox form").submit();
    }
}
$("a.denybtn").click(function(){
    var applyid=$(this).attr("applyid");
    $("#applyid").val(applyid);
    popBox.open($("#pop_tpl").html())
    return false;
})

$("a.oper").click(function(){
    popBox.open($("#pop_tpl").text());
    return false;
});


</script>
<?
include("common/footer.html");